package cn.elwy.rcp.core.model.ui.progress;

import org.eclipse.core.runtime.IProgressMonitor;

public class ProgressMonitor implements IProgressMonitor {

  private IProgressMonitor monitor;

  public ProgressMonitor(IProgressMonitor monitor) {
    this.monitor = monitor;
  }

  public void beginTask(String name, int totalWork) {
    if (monitor != null) {
      monitor.beginTask(name, totalWork);
    }
  }

  public void done() {
    if (monitor != null) {
      monitor.done();
    }
  }

  public void internalWorked(double work) {
    if (monitor != null) {
      monitor.internalWorked(work);
    }
  }

  public boolean isCanceled() {
    if (monitor != null) {
      return monitor.isCanceled();

    } else {
      return false;
    }
  }

  public void setCanceled(boolean value) {
    if (monitor != null) {
      monitor.setCanceled(value);
    }
  }

  public void setTaskName(String name) {
    if (monitor != null) {
      monitor.setTaskName(name);
    }
  }

  public void subTask(String name) {
    if (monitor != null) {
      monitor.subTask(name);
    }
  }

  public void worked(int work) {
    if (monitor != null) {
      monitor.worked(work);
    }
  }

  public IProgressMonitor getMonitor() {
    return monitor;
  }

  public void setMonitor(IProgressMonitor monitor) {
    this.monitor = monitor;
  }

}
